package com.rmondjone.face.ViewModel

import com.ant.http.HttpManager
import com.rmondjone.androidcamerademo.CommonService
import com.rmondjone.androidcamerademo.FileBean
import okhttp3.MediaType.Companion.toMediaType
import okhttp3.MultipartBody
import okhttp3.RequestBody.Companion.asRequestBody
import java.io.File

/**
 * copyright：
 * @author：anthui creation date： .
 * @since: 1.0.0
 * @describe:
 */
class FileViewModel {

    fun upFile(path: String, onCallBack: OnCallBack<FileBean>) {
        var file = File(path)
        val filBody = file.asRequestBody("file/*".toMediaType())
        val part = MultipartBody.Part.createFormData("file", file.name, filBody)

        HttpManager.getService(CommonService::class.java).upFile(part).enqueue(onCallBack)

    }


}